using UnityEditor;
using UnityEngine;
using Yoozoo.Gameplay.City;

namespace Yoozoo.Gameplay.CityEditor
{
    [CustomEditor(typeof(CityWallComponent))]
    public class CityWallComponentEditor : UnityEditor.Editor
    {
        private CityWallComponent _wallComponent;
        private bool isPlayEffect;

        private void OnEnable()
        {
            _wallComponent = target as CityWallComponent;
        }

        public override void OnInspectorGUI()
        {
            isPlayEffect = GUILayout.Toggle(isPlayEffect, "播放解锁特效");

            GUILayout.BeginHorizontal();
            CreateUnlockAreaButton(0);
            CreateUnlockAreaButton(1);
            CreateUnlockAreaButton(2);
            GUILayout.EndHorizontal();
            
            GUILayout.BeginHorizontal();
            CreateUnlockAreaButton(3);
            CreateUnlockAreaButton(4);
            CreateUnlockAreaButton(5);
            GUILayout.EndHorizontal();
            //
            // GUILayout.BeginHorizontal();
            // CreateUnlockAreaButton(6);
            // CreateUnlockAreaButton(7);
            // CreateUnlockAreaButton(8);
            // GUILayout.EndHorizontal();
            
        
            base.OnInspectorGUI();
        }

        private void CreateUnlockAreaButton(int index)
        {
            int areaId = _wallComponent.GetAreaId(index);
            if (GUILayout.Button("区域" + areaId, GUILayout.Height(30)))
            {
                _wallComponent.UnlockArea(areaId, isPlayEffect);
            }
        }
    }
}
